<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	template = "/WEB-INF/template/templateAreaLavoro.xhtml">


	<ui:define name="topAreaLavoro">
	
		
	
		<rich:toolbar height="30" >
		
  			<a4j:commandLink action="#{tab.setNewObject('Nuovo Cliente')}"   render="pannelloDatiCliente"  >
  				<h:graphicImage value="#{pathImmagini.pathImmagineAggiungiSoggetto}"/>
  			</a4j:commandLink>
  			
			<a4j:commandLink  action="#{tabsBean.addCliente(tab.object)}" execute="pannelloDatiCliente" render="pannelloDatiCliente" >
				<h:graphicImage value="#{pathImmagini.pathImmagineSalva}"/>
			</a4j:commandLink>
			
			<a4j:commandLink action="#{stampaController.stampaOrdine(tab.object)}">
				<h:graphicImage value="#{pathImmagini.pathImmagineStampa}"/>
			</a4j:commandLink>
			
			
			
		</rich:toolbar>	
		<br/>
	</ui:define>
	
	
	<ui:define name="center1AreaLavoro">
		
		
	
		<rich:panel >
			<f:facet name="header">
				<h:graphicImage value="#{pathImmagini.pathImmagineCliente}"/>
				Dati Cliente
			</f:facet>
		
			<rich:messages for="gv" />
			<rich:graphValidator id="gv" value="#{tab.object} ">
				<h:panelGrid id="pannelloDatiCliente"  columns="3"  border="0">
				
					<h:outputLabel value="Denominazione" />
					<h:inputText id="denominazione" value="#{tab.object.denominazione}" >
						<rich:validator event="blur" />
					</h:inputText>
					<rich:message for="denominazione" />
					   
					<h:outputLabel value="Codice Fiscale" />
					<h:inputText id="codiceFiscale" value="#{tab.object.codiceFiscale}" />
					<rich:message for="codiceFiscale" />
					
					
					<h:outputLabel value="Via" />
					<h:inputText id="via" value="#{tab.object.indirizzo.via}" />
					<rich:message for="via" />
					
					<h:outputLabel value="Localita" />
					<h:inputText id="localita" value="#{tab.object.indirizzo.localita}" />
					<rich:message for="localita" />
					
					
					<h:outputLabel value="Provincia" />
					<h:inputText id="provincia" value="#{tab.object.indirizzo.provincia}" />
					<rich:message for="provincia" />
				
					
				
					<h:outputText value="Regione" />
					<rich:select id="regione" value="#{tab.object.regione}" converter="#{regioneConverter}">
						<f:selectItems value="#{selectBean.regioni}" ></f:selectItems>
					</rich:select>
					<rich:message for="regione" />
				
					<h:outputLabel value="Telefono" />
					<h:inputText id="telefono" value="#{tab.object.telefono}" />
					<rich:message for="telefono" />
			
					<h:outputLabel value="Email" />
					<h:inputText id="email" value="#{tab.object.email}" />
					<rich:message for="email" />
					
					<h:outputLabel value="Tipo Pagamento" />
					<h:inputText id="tipopagamento" value="#{tab.object.tipoPagamento}" />
					<rich:message for="tipopagamento" />
				
				
					<h:outputLabel value="Abilitato" />
					<h:selectBooleanCheckbox id="abilitato" value="#{tab.object.abilitato}" />
					<rich:message for="abilitato" />

					
					<h:outputLabel value="Cap" />
					<h:inputText id="cap" value="#{tab.object.cap}" />
					<rich:message for="cap" />
					
					<h:outputLabel value="Principal" />
					<h:inputText id="principal" value="#{tab.object.principal}" />
					<rich:message for="principal" />
					
					
				<a4j:status  name="saveStatus"   	
																onsuccess="#{rich:component('confirmPanel')}.show();"  
																onerror="#{rich:component('errorPanel')}.show();"   />
				
				<ui:include src="/popup/popupsUtility.xhtml" />	
				</h:panelGrid>
			</rich:graphValidator>
			</rich:panel>
			<br/>
	</ui:define>

	<ui:define name="center2AreaLavoro">
		
			<rich:panel>
				<f:facet name="header">
					<h:graphicImage value="#{pathImmagini.pathImmagineCerca}" />
					Risultati
				</f:facet>
				
					<h:panelGrid columns="1" border="0">
						<a4j:commandButton value="Cerca" actionListener="#{selectBean.findAllRegioni}" render="tabellaClienti" execute="@this" />
					
  				
  			
					</h:panelGrid>
					
					<rich:dataTable id="tabellaClienti" value="#{selectBean.regioni}" var="regioni" style="width: 100%;">
							<f:facet name="header">
								<rich:columnGroup>
									<rich:column colspan="7">Tabella Riepilogo Clienti Regioe</rich:column>
								</rich:columnGroup>
							</f:facet>
														
							<rich:column colspan="7" rendered="#{regioni.clienti.size() > 0}" >
								<rich:collapsibleSubTableToggler for="sbtable"   />
								<h:outputText value="#{regioni.nomeRegione}" />
							</rich:column>
							
							<rich:collapsibleSubTable  id="sbtable" value="#{regioni.clienti}" var="cliente" rendered="#{regioni.clienti.size() > 0}" expanded="#{selectBean.expans}" >
								
								<rich:column>
									<f:facet name="header">ID</f:facet>
									<h:outputText value="#{cliente.idCliente}" />
								</rich:column>
							
								
								<rich:column>
									<f:facet name="header">Denominazione</f:facet>
									<h:outputText value="#{cliente.denominazione}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Codice Fiscale</f:facet>
									<h:outputText value="#{cliente.codiceFiscale}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Provincia</f:facet>
									<h:outputText value="#{cliente.indirizzo.provincia}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Telefono</f:facet>
									<h:outputText value="#{cliente.telefono}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Attivo</f:facet>
									<h:outputText value="#{cliente.abilitato}" />
								</rich:column>
								
								<rich:column>
									<f:facet name="header">Resoconto</f:facet>
									<a4j:commandLink 	value="Resoconto" 
														action="#{tabsBean.creaTabRisultatiNew('tabResocontoCliente','/pages/Clienti/pannelloResocontoCliente.xhtml')}" 
														render="tabsPanel" execute="@this"
														/>
								</rich:column>
								
								
								
							</rich:collapsibleSubTable>
						
						
						
					</rich:dataTable>
						
						
			</rich:panel>
			<br/>
	</ui:define>
	
	
	<ui:define name="footerAreaLavoro">
		
	</ui:define>
</ui:composition>